using System;
using System.Collections.Generic;
using System.Text;

namespace Hoshimi
{
    public class NeuroControllerShooterGroup_ManageState : State
	{
		#region Singleton

		// Fields
		protected static NeuroControllerShooterGroup_ManageState instance;

		// Constructor
		protected NeuroControllerShooterGroup_ManageState() : base() { }

		// Methods
		public static NeuroControllerShooterGroup_ManageState Instance()
		{
			// Uses "Lazy initialization"
			if( instance == null ) 
				instance = new NeuroControllerShooterGroup_ManageState();

			return instance;
		}

		#endregion

		public override bool Play( Unit unit )
		{
			NeuroControllerShooterGroup group = (NeuroControllerShooterGroup) unit;

			group.UpdateNeuroControllerLocation();

			group.AskRequireBot();

			if (group.IsNeuroControllerToBeDone())
			{
				return true;
			}

			if (group.IsPierreNanoAIDead || group.GetNeuroControllerCount() <= 0)
			{
				group.myStateMachine.ChangeState(NeuroControllerShooterGroup_ReleaseState.Instance());
				return false;
			}

			return true;
		}
	}
}
